import httpRequest from "@/util/httpRequest";

export default {
  /**
   * 紧急程度
   */
  urgentLevelMap: {
    0: '未知',
    1: '不重要不紧急',
    2: '重要不紧急',
    3: '紧急不重要',
    4: '重要紧急'
  },
  /**
   * 紧急程度tag顔色
   */
  urgentLevelColorMap: {
    1: {color:'#E6F4FE',textcolor:'#288EF4'},
    2: {color:'#faebd7',textcolor:'#f49328'},
    3: {color:'#d4f0b3',textcolor:'#8bc34a'},
    4: {color:'#ffe1e1',textcolor:'#ad0000'}
  },
  /**
   * tag 紧急程度的选择框数据
   */
  urgentLevelLabMap: [{
      name: "重要紧急",
      id: 4,
      isSel: false
    },
    {
      name: "紧急不重要",
      id: 3,
      isSel: false
    },
    {
      name: "重要不紧急",
      id: 2,
      isSel: false
    },
    {
      name: "不紧急不重要",
      id: 1,
      isSel: false
    }
  ],
   /**
   * tag 紧急程度的选择框数据 （不被修改）
   */
    urgentLevelLabMap2: [{
      name: "重要紧急",
      id: 4,
      isSel: false
    },
    {
      name: "重要不紧急",
      id: 3,
      isSel: false
    },
    {
      name: "紧急不重要",
      id: 2,
      isSel: false
    },
    {
      name: "不紧急不重要",
      id: 1,
      isSel: false
    }
  ],
  /**
   * 任务状态
   */
  statusMap: {
    0: '已接单',
    1: '进行中',
    2: '已取消',
    3: '已完成'
  },
  /**
   * 任务状态 1:进行中,2:已完成已采纳3:已完成未采纳4:已取消
   */
   statusLabMap: 
   [{
     name: "进行中",
     id: 1
   },
   {
     name: "已完成已采纳",
     id: 2
   },
   {
     name: "已完成未采纳",
     id: 3
   },
   {
     name: "已取消",
     id: 4
   }],
  /**
   * 重要程度 1-5 标识 1-5颗星
   */
  importLevelMap: {
    1: '1颗星',
    2: '2颗星',
    3: '3颗星',
    4: '4颗星',
    5: '5颗星'
  },
  /**
   * 重要程度选择框数据 1-5 标识 1-5颗星
   */
  importLevelLabMap: [{
    name: '1颗星',
    id: 1,
    isSel: false
  }, {
    name: '2颗星',
    id: 2,
    isSel: false
  }, {
    name: '3颗星',
    id: 3,
    isSel: false
  }, {
    name: '4颗星',
    id: 4,
    isSel: false
  }, {
    name: '5颗星',
    id: 5,
    isSel: false
  }],
  /**
   * 采纳状态(ac_adopt_status) 0:未采纳, 1:采纳
   */
  acAdoptStatusMap: {
    0: '未采纳',
    1: '采纳'
  },
  /**
   * 接单人认为任务类型
   */
  taskTypeMap: {
    1: '本职工作',
    2: '组织建设',
    3: '额外工作'
  },
  /**
   * tag接单人认为任务类型
   */
  taskTypeLabMap: [{
      name: "本职工作",
      id: 1,
    },
    {
      name: "组织建设",
      id: 2,
    },
    {
      name: "额外贡献",
      id: 3,
    },
  ],
  /**
   * 根据订单状态返回状态与时间过滤后的字段
   * ac_add_time
   * ac_finish_time
   * ac_adopt_time
   * ac_adopt_status
   * 
   */
  getTimeType(taskAcceptList) {
    let acStatusForTime = '';
    let status = taskAcceptList.ac_status;
    let ac_add_time = taskAcceptList.ac_add_time ? new Date(taskAcceptList.ac_add_time) :  new Date(taskAcceptList.addTime);
    let ac_finish_time = new Date(taskAcceptList.ac_finish_time);
    let ac_adopt_time = new Date(taskAcceptList.ac_adopt_time);
    let ac_adopt_status = taskAcceptList.ac_status;
    ac_add_time = (ac_add_time.getMonth() + 1) + '-' + ac_add_time.getDate();
    ac_finish_time = (ac_finish_time.getMonth() + 1) + '-' + ac_finish_time.getDate();
    ac_adopt_time = (ac_adopt_time.getMonth() + 1) + '-' + ac_adopt_time.getDate();
    switch (status) {
      case 0:
        acStatusForTime = ac_add_time + this.statusMap[status];
        break;
      case 1:
        acStatusForTime = ac_add_time + this.statusMap[status];
        break;
      case 2:
        acStatusForTime = ac_add_time + this.statusMap[status];
        break;
      case 3:
        acStatusForTime =
          ac_adopt_status == 1 ? ac_adopt_time + ' ' + this.acAdoptStatusMap[ac_adopt_status] : ac_finish_time + ' ' + this.statusMap[status];
        break;
      default:
          acStatusForTime = ac_add_time + ' ' + '发布'
        break;
    }
    return acStatusForTime;
  },
  /**
   * 根据订单状态返回状态与时间过滤后的字段
   * ac_add_time
   * ac_finish_time
   * ac_adopt_time
   * ac_adopt_status
   * 
   */
   getTimer(taskAcceptList) {
    let acStatusForTime = '';
    let status = taskAcceptList.ac_status;
    let ac_add_time = taskAcceptList.ac_add_time ? new Date(taskAcceptList.ac_add_time) :  new Date(taskAcceptList.addTime);
    let ac_finish_time = new Date(taskAcceptList.ac_finish_time);
    let ac_adopt_time = new Date(taskAcceptList.ac_adopt_time);
    let ac_adopt_status = taskAcceptList.ac_status;
    ac_add_time = (ac_add_time.getMonth() + 1) + '-' + ac_add_time.getDate() + ' ' + this.getStr(ac_add_time.getHours()) + ':' + this.getStr(ac_add_time.getMinutes());
    ac_finish_time = (ac_finish_time.getMonth() + 1) + '-' + ac_finish_time.getDate() + ' ' + this.getStr(ac_finish_time.getHours()) + ':' + this.getStr(ac_finish_time.getMinutes());
    ac_adopt_time = (ac_adopt_time.getMonth() + 1) + '-' + ac_adopt_time.getDate() + ' ' + this.getStr(ac_adopt_time.getHours()) + ':' + this.getStr(ac_adopt_time.getMinutes());
    switch (status) {
      case 0:
        acStatusForTime = ac_add_time + '　' + this.statusMap[status];
        break;
      case 1:
        acStatusForTime = ac_add_time + '　' + this.statusMap[status];
        break;
      case 2:
        acStatusForTime = ac_add_time + '　' + this.statusMap[status];
        break;
      case 3:
        acStatusForTime =
          ac_adopt_status == 1 ? ac_adopt_time + ' ' + this.acAdoptStatusMap[ac_adopt_status] : ac_finish_time + '　' + this.statusMap[status];
        break;
      default:
          acStatusForTime = ac_add_time + '　' +'发布'
        break;
    }
    return acStatusForTime;
  },
  getStr(timeNum){
    return timeNum < 10 ? "0" + timeNum : timeNum;
  },
  /**
   * 返回@部门
   * deptIds：部门IDs  string：1，2，3
   */
   depts:[],
   async getTargetDeptIds	(deptIds) {
     let ids = deptIds.split(',');
     let deptNames ='';
     if(this.depts.length == 0){
      // await httpRequest.post("返回用户所在的部门和全部门列表", {}).then(res => {
      //   this.depts = res.data.alldept;
      //   deptNames = this.getForDept(ids);
      // });
     }else{
        deptNames = this.getForDept(ids);
     }
    return deptNames;
  },
   /**
   * 返回所有部門
   * deptIds：部门IDs  string：1，2，3
   */
  async getDepts	() {
    if(this.depts.length == 0){
     await httpRequest.post("返回用户所在的部门和全部门列表", {}).then(res => {
       this.depts = res.data.alldept;
     });
    }
   return this.depts;
 },
  getForDept(ids){
    let arr = '';
    for (let i = 0; i < this.depts.length; i++) {
      const dept = this.depts[i];
      for (let j = 0; j < ids.length; j++) {
        const id = ids[j];
        dept.id == id ? arr+=('@'+ dept.name + "," ):null;
      }
    }
    return arr;
  },
   /**
   * 返回大厅所有tag下的任务数
   * 
   */
    tagNums:null,
    async getTagNums() {
      if(this.tagNums == null){
      //  await httpRequest.post("查询任务大厅中各种任务的数量", {}).then(res => {
      //    this.tagNums = res.data;
      //  });
      }
     return this.tagNums;
   },
  // 部门筛选 返回部门下的任务数
   // eslint-disable-next-line no-unused-vars
   getDeptTaskNum(id){
    return ''
    // return this.tagNums['deptTaskNum'][id]
   },
  // 紧急程度 返回紧急程度的任务数
   // eslint-disable-next-line no-unused-vars
   getUrgentTaskNum(id){
    // return this.tagNums['urgentTaskNum'][id]
    return ''
   },
    /**
   * 返回我的所有tag下的任务数
   * 
   */
     myMissionsTagNums:null,
     async getMyMissionsTagNums() {
       if(this.myMissionsTagNums == null){
        // await httpRequest.post("查询我的接单页面中各种任务的数量", {}).then(res => {
        //   this.myMissionsTagNums = res.data;
        // });
       }
      return this.myMissionsTagNums;
    },
    getTaskLabMap(id,key){
      return this.myMissionsTagNums[key][id]
     },
      /**
   * 返回历史提醒的人和记录
   * 
   */
       historyTip:null,
       async getHistoryTipList() {
          // await httpRequest.post("查询我发布的任务历史提醒的人和记录", {}).then(res => {
          //   this.historyTip = res.data;
          // });
        return this.historyTip;
      },
}